package org.swfer.UIC 
{
	import flash.display.MovieClip;
	import flash.geom.Rectangle;
	
	/**
	 * 进度条
	 * 必须部件 up
	 * @author swfer
	 */
	public class ProgressBar extends Component 
	{
		protected var _value:Number;
		
		public function ProgressBar(view:MovieClip) 
		{
			super(view);
		}
		
		override protected function init():void
		{
			view.scrollRect = new Rectangle(0, 0, view.width, view.height);
			view['up'].x = -view.scrollRect.width;
		}
		
		/**
		 * 当前进度[0~1]的浮点数
		 */
		public function get value():Number { return _value;}
		public function set value(v:Number):void 
		{
			if (_value == v) return;
			
			if (v < 0) v = 0;
			if (v > 1) v = 1;
			
			_value = v;
			view['up'].x = -view.scrollRect.width * (1-v);
		}
	}

}